package com.bdcom.nms.NmsCollect.test;

import org.apache.log4j.Logger;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import com.bdcom.nms.NmsCollect.test.po.Users;
import com.bdcom.nms.NmsCollect.test.service.UsersService;
import com.bdcom.nms.NmsCollect.test.service.Uservice;
import com.bdcom.nms.NmsCollect.test.springtest.C;

/**
 * 这是一个spring的测试类
 * 
 * @author Administrator
 *
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:CONFIG\\applicationContext.xml")
public class AppTest_1 extends AbstractTransactionalJUnit4SpringContextTests {
	
	static  Logger _log=Logger.getLogger(AppTest_1.class);

	/**
	 * 此处为junit3.8的测试代码
	 */

	// ApplicationContext ctx ;
	//
	// protected void setUp() throws Exception {
	// // TODO Auto-generated method stub
	// super.setUp();
	//
	// ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
	//
	// }
	/**
	 * spring ioc测试代码
	 */
	// public void testSpring(){
	//
	// System.out.println("-----------------Spring测试开始！");
	//
	// B b=(B) ctx.getBean("classB");
	//
	// System.out.println("A的Name:"+b.getClsa().getName());
	//
	// System.out.println("-----------------Spring测试结束！ ");
	//
	// }

	/**
	 * spring test
	 */
	@Autowired
	private UsersService usersService;

	@Autowired
	private Uservice uservice;
	
	@Autowired
	private C c;

	@Test
	public void testJpa() {

		System.out.println("-------------------开始测试JPA");

		usersService.findByUid(1);

		System.out.println("-------------------结束测试JPA");

	}

	@Test
	public void testJPA() {

		// Users u=new UserviceImpl().getUsersByID(1);

		Users u = uservice.getUsersByID(1);

		System.out.println(".............start...........JPATEST");

		System.out.println(u);

		System.out.println("..........terminate......JPATEST");

	}
	
	@Test
	public void testSnmpHibernate() throws Exception{
		
		_log.info("............................start snmp test.................");
		
		_log.info("172.16.21.24的在线时间:"+c.getSystemUpTime());
		
		_log.info("............................end  snmp test.................");
		
	}

}
